﻿<cfsilent>
	<cfscript>

		event.setArg("pageTitle", "选课管理 - 学期开课情况 - 撤合班");

		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		chooseProp = getProperty("serviceFactory").getBean("choosePropertyAdvice");
		
		termId = event.getArg("TermID");
		depId = event.getArg("DepID");

		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		/* 载入教学任务 */
		switch(taskType){
			case "P":
				sql = "	SELECT
							tc.cid,tc.course_name,tci.institute_name,tc.period_theory,tc.course_credit,t.task_limite,
							tt.tch_name,t.task_chooesd,tt.tch_id,t.task_week,t.task_period,tcu.campus_name,tct.cr_type_name,t.task_classes,t.tsk_id,tc.period
						FROM
							t_task t INNER JOIN t_course tc ON tc.cid = t.cid INNER JOIN t_institute tci ON tc.institute_id = tci.institute_id
							INNER JOIN t_teacher tt ON tt.tch_id = t.tch_id INNER JOIN t_campus tcu ON tcu.campus_id = t.campus_id
							INNER JOIN t_classroom_type tct ON tct.cr_type = t.cr_type
						WHERE
							t.tsk_id = :taskId ";
				break;
			case "C":
				sql = "	SELECT
							tc.cid,tc.course_name,tci.institute_name,tc.period_theory,tc.course_credit,t.task_limite,
							tt.tch_name,t.task_chooesd,tt.tch_id,t.task_week,t.task_period,tcu.campus_name,tct.cr_type_name,t.tsk_id,tc.period
						FROM
							t_common_task t INNER JOIN t_course tc ON tc.cid = t.cid INNER JOIN t_institute tci ON tc.institute_id = tci.institute_id
							INNER JOIN t_teacher tt ON tt.tch_id = t.tch_id INNER JOIN t_campus tcu ON tcu.campus_id = t.campus_id
							INNER JOIN t_classroom_type tct ON tct.cr_type = t.cr_type
						WHERE
							t.tsk_id = :taskId ";
				break;
			case "R":
				sql = "	SELECT
							tc.cid,tc.course_name,tci.institute_name,tc.period_theory,tc.course_credit,t.task_limite,
							tt.tch_name,t.task_chooesd,tt.tch_id,t.task_week,t.task_period,tcu.campus_name,tct.cr_type_name,t.tsk_id,tc.period
						FROM
							t_reopen_task t INNER JOIN t_course tc ON tc.cid = t.cid INNER JOIN t_institute tci ON tc.institute_id = tci.institute_id
							INNER JOIN t_teacher tt ON tt.tch_id = t.tch_id INNER JOIN t_campus tcu ON tcu.campus_id = t.campus_id
							INNER JOIN t_classroom_type tct ON tct.cr_type = t.cr_type
						WHERE
							t.tsk_id = :taskId ";
				break;
			case "T":
				sql = "	SELECT
							tc.cid,tc.course_name,tci.institute_name,tc.period_theory,tc.course_credit,t.task_limite,
							tt.tch_name,t.task_chooesd,tt.tch_id,t.task_week,t.task_period,tcu.campus_name,tct.cr_type_name,t.tsk_id,tc.period
						FROM
							t_sport_task t INNER JOIN t_course tc ON tc.cid = t.cid INNER JOIN t_institute tci ON tc.institute_id = tci.institute_id
							INNER JOIN t_teacher tt ON tt.tch_id = t.tch_id INNER JOIN t_campus tcu ON tcu.campus_id = t.campus_id
							INNER JOIN t_classroom_type tct ON tct.cr_type = t.cr_type
						WHERE
							t.tsk_id = :taskId ";
				break;
		}
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "taskId", value = taskId, cfsqltype = "cf_sql_varchar");
		rs_taskEntity = queryObj.execute(sql = sql).getResult();
		
		/* 载入选课名单 */
		sql = "	SELECT
					stu.stu_id,stu.stu_name,
					clz.cls_name,
					ct.turn,cp.prop_name,
					sc.task_type,sc.st,sc.retaking,sc.choose_time,sc.choose_prop
				FROM
					t_student_course sc INNER JOIN t_student stu ON sc.stu_id = stu.stu_id INNER JOIN t_class clz ON clz.cls_id = stu.cls_id
					INNER JOIN t_choose_turn ct ON sc.ct = ct.ct INNER JOIN t_course_prop cp ON cp.prop_id = sc.prop_id
				WHERE
					sc.task_id = :taskId 
					AND
					sc.term_id = :termId 
				ORDER BY
					clz.cls_name,stu.stu_id";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "taskId", value = taskId, cfsqltype = "cf_sql_varchar");
		queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
		rs_chooser = queryObj.execute(sql = sql).getResult();
		
		courseId = rs_taskEntity.cid;
		
		/* 载入备选教学任务 */
		rs_taskResign = queryNew("tsk_id");
		
		switch ( taskType ) {

			case "P":
				sql = "	SELECT
							t.tsk_id,tc.course_name,t.cidx,tt.tch_name,tcu.campus_name,t.task_limite,t.task_chooesd,t.task_capacity,t.task_week
						FROM
							t_task t INNER JOIN t_course tc ON tc.cid = t.cid INNER JOIN t_teacher tt ON tt.tch_id = t.tch_id
							INNER JOIN t_campus tcu ON tcu.campus_id = t.campus_id
						WHERE
							t.term_id = :termId 
							AND
							tc.cid = :courseId 
							AND t.tsk_id != :taskId 
							AND SUBSTR(t.task_prop,7,1) = '0'
						ORDER BY
							tcu.campus_name,tt.tch_name,t.cidx";
				
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "taskId", value = taskId, cfsqltype = "cf_sql_varchar");
				queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
				queryObj.addParam(name = "courseId", value = courseId, cfsqltype = "cf_sql_varchar");
				rs_taskResign = queryObj.execute(sql = sql).getResult();
				
				break;

			case "C":
				sql = "	SELECT
							t.tsk_id,tc.course_name,t.cidx,tt.tch_name,tcu.campus_name,t.task_limite,t.task_chooesd,t.task_capacity,t.task_week
						FROM
							t_common_task t INNER JOIN t_course tc ON tc.cid = t.cid INNER JOIN t_teacher tt ON tt.tch_id = t.tch_id
							INNER JOIN t_campus tcu ON tcu.campus_id = t.campus_id
						WHERE
							t.term_id = :termId 
							AND
							tc.cid = :courseId 
							AND t.tsk_id != :taskId 
							AND SUBSTR(t.task_prop,7,1) = '0'
						ORDER BY
							tcu.campus_name,tt.tch_name,t.cidx";
				
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "taskId", value = taskId, cfsqltype = "cf_sql_varchar");
				queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
				queryObj.addParam(name = "courseId", value = courseId, cfsqltype = "cf_sql_varchar");
				rs_taskResign = queryObj.execute(sql = sql).getResult();
				
				break;
			
			case "R":
				sql = "	SELECT
							t.tsk_id,tc.course_name,t.cidx,tt.tch_name,tcu.campus_name,t.task_limite,t.task_chooesd,t.task_capacity,t.task_week
						FROM
							t_reopen_task t INNER JOIN t_course tc ON tc.cid = t.cid INNER JOIN t_teacher tt ON tt.tch_id = t.tch_id
							INNER JOIN t_campus tcu ON tcu.campus_id = t.campus_id
						WHERE
							t.term_id = :termId 
							AND
							tc.cid = :courseId 
							AND t.tsk_id != :taskId 
							AND SUBSTR(t.task_prop,7,1) = '0'
						ORDER BY
							tcu.campus_name,tt.tch_name,t.cidx";
				
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "taskId", value = taskId, cfsqltype = "cf_sql_varchar");
				queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
				queryObj.addParam(name = "courseId", value = courseId, cfsqltype = "cf_sql_varchar");
				rs_taskResign = queryObj.execute(sql = sql).getResult();
				
				break;
			
			case "T":
				sql = "	SELECT
							t.tsk_id,tc.course_name,t.cidx,tt.tch_name,tcu.campus_name,t.task_limite,t.task_chooesd,t.task_capacity,t.task_week
						FROM
							t_sport_task t INNER JOIN t_course tc ON tc.cid = t.cid INNER JOIN t_teacher tt ON tt.tch_id = t.tch_id
							INNER JOIN t_campus tcu ON tcu.campus_id = t.campus_id
						WHERE
							t.term_id = :termId 
							AND
							tc.cid = :courseId 
							AND t.tsk_id != :taskId 
							AND SUBSTR(t.task_prop,7,1) = '0'
						ORDER BY
							tcu.campus_name,tt.tch_name,t.cidx";
				
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "taskId", value = taskId, cfsqltype = "cf_sql_varchar");
				queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
				queryObj.addParam(name = "courseId", value = courseId, cfsqltype = "cf_sql_varchar");
				rs_taskResign = queryObj.execute(sql = sql).getResult();
				
				break;
				
		}
		
		targetArgs = structNew();
		structInsert(targetArgs, "TID", termId, true);
		structInsert(targetArgs, "DepID", depId, true);

		
		currentTab = event.getArg("TabID", "labTask");
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('taskClass', targetArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学任务</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>撤销教学任务
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labTask">class="active"</cfif> id="labTask" tabTarget="Task">撤销教学任务</span>
						<span <cfif currentTab eq "labStudent">class="active"</cfif> id="labStudent" tabTarget="Student">选课名单</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
					
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
					
					});
					// -->
					//]]>
				</script>

				<div id="Task" class="tabContent">
					
					<div class="noticeBlock">
						<h3>《<cfoutput>#rs_taskEntity.course_name#</cfoutput>》任务概况</h3>
						<p>
							任课单位: <cfoutput>#rs_taskEntity.institute_name#</cfoutput> 
							总学时 <em><cfoutput>#rs_taskEntity.period#</cfoutput></em>, 其中理论学时 <em><cfoutput>#rs_taskEntity.period_theory#</cfoutput></em>. 
							课程总学分:<em><cfoutput>#numberFormat(rs_taskEntity.course_credit, '_.00')#</cfoutput></em>
							计划人数: <em><cfoutput>#rs_taskEntity.task_limite#</cfoutput></em>
							选课人数: <em><cfoutput>#rs_taskEntity.task_chooesd#</cfoutput></em>
						</p>
						<p>	
							<span class="img icon16x16 message"></span>
							主讲教师: <cfoutput>#rs_taskEntity.tch_name#</cfoutput><em>(<cfoutput>#rs_taskEntity.tch_id#</cfoutput>)</em>
							排课周次: <em><cfoutput>#rs_taskEntity.task_week#</cfoutput></em> 
							周学时: <em><cfoutput>#rs_taskEntity.task_period#</cfoutput></em>
						</p>
						<p>	
							<span class="img icon16x16 building"></span>
							校区: <cfoutput>#rs_taskEntity.campus_name#</cfoutput>
							教学场地: <cfoutput>#rs_taskEntity.cr_type_name#</cfoutput>
							
							<cfif taskType eq "P">
								<span class="img icon16x16 card"></span>
								上课班级: <cfoutput>#rs_taskEntity.task_classes#</cfoutput>
							</cfif>
						</p>
						<hr/>
					</div>
					
					<form id="formEdit" onSubmit="javascript:return processVerfiyForm('formEdit');" class="formWrapper" method="post" action="<cfoutput>#buildURL('taskClassCancelDo')#</cfoutput>">
						
						<input type="hidden" name="TSK" value="<cfoutput>#rs_taskEntity.tsk_id#</cfoutput>" />
						<input type="hidden" name="TT" value="<cfoutput>#taskType#</cfoutput>" />
						
						<div class="label">
							<span class="req">*</span><b>选课学生处理</b>
							<div class="secondRow">
								<input name="ProcessStudent" type="radio" class="typeRadio" value="1" /> 保留选课记录
								<br/>
								<input name="ProcessStudent" type="radio" class="typeRadio" value="2" checked="checked" /> 删除选课记录
								<cfif rs_taskResign.recordCount>
									<br/>
									<input cid="<cfoutput>#courseId#</cfoutput>" name="ProcessStudent" id="Combine" type="radio" class="typeRadio" value="3" /> 合并到其他教学班
								</cfif>
							</div>
							<cfif rs_taskResign.recordCount>
								<div cid="<cfoutput>#courseId#</cfoutput>" class="secondRow hidden_elem">
									<table>
										<thead>
											<tr>
												<td></td>
												<td>教学班</td>
												<td>课序号</td>
												<td>校区</td>
												<td>计划</td>
												<td>已选</td>
												<td>最大容量</td>
												<td>周次</td>
											</tr>
										</thead>
										<tbody>
											<cfset row = 0 />
                                            <cfloop query="rs_taskResign">
												<cfset row++ />
												<tr>
													<td><input name="TaskIDReSign" type="radio" class="typeRadio" value="<cfoutput>#rs_taskResign.tsk_id#</cfoutput>" <cfif row eq 1>checked="checked"</cfif> /></td>
													<td><cfoutput>#rs_taskResign.course_name#</cfoutput>-<cfoutput>#rs_taskResign.tch_name#</cfoutput></td>
													<td class="numeric"><cfoutput>#rs_taskResign.cidx#</cfoutput></td>
													<td><cfoutput>#rs_taskResign.campus_name#</cfoutput></td>
													<td class="numeric"><cfoutput>#rs_taskResign.task_limite#</cfoutput></td>
													<td class="numeric"><cfoutput>#rs_taskResign.task_chooesd#</cfoutput></td>
													<td class="numeric"><cfif rs_taskResign.task_capacity gt 0><cfoutput>#rs_taskResign.task_capacity#</cfoutput><cfelse>-</cfif></td>
													<td class="numeric"><cfoutput>#rs_taskResign.task_week#</cfoutput></td>
												</tr>
											</cfloop>
										</tbody>
									</table>
								</div>
								<script language="javascript" type="text/javascript">
									//<![CDATA[
									<!--
									$(document).ready(function() {
										
										$("input[name='ProcessStudent']").change(function(){
											
											var $trigger = $(this);
											
											var courseId = $trigger.attr('cid');
											
											if ( courseId ) {
												$("div[cid].secondRow").removeClass("hidden_elem");
											}
											else {
												$("div[cid].secondRow").addClass("hidden_elem");
											}
											
										});
										
									});
									// -->
									//]]>
								</script>
							</cfif>
						</div>
						
						<hr/>
						<div class="lable">
							<input class="button4" type="submit" value="执行" />
							<input id="formReset" class="button" type="reset" value="重设表格" />
						</div>
					</form>
					
				</div>

				<div id="Student" class="tabContent">
					
					<div class="noticeBlock">
						<h3>选课学生明细</h3>
						<hr/>
					</div>
					
					<cfset row = 0 />
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="22"></td>
								<td>学号</td>
								<td>姓名</td>
								<td>行政班</td>
								<td width="48">课程性质</td>
								<td width="48">选课方式</td>
								<td width="24">重修</td>
								<td width="48">选课轮次</td>
								<td>选课时间</td>
								<td width="18"></td>
							</tr>
						</thead>
						<tbody>
                            <cfloop query="rs_chooser">
								<cfset row++ />
								<cfset chooseProp.parseProperty(rs_chooser.choose_prop) />
								<tr class="editRows">
									<td class="index"><cfoutput>#row#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_chooser.stu_id#</cfoutput></span></td>
									<td><cfoutput>#rs_chooser.stu_name#</cfoutput></td>
									<td><cfoutput>#rs_chooser.cls_name#</cfoutput></td>
									<td><cfoutput>#rs_chooser.prop_name#</cfoutput></td>
									<td><cfoutput>#dictAdvice.getStudyType( rs_chooser.st )#</cfoutput></td>
									<td><cfif rs_chooser.retaking eq "1">是</cfif></td>
									<td><cfoutput>#rs_chooser.turn#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#datetimeAdvice.formatDatetimeString( rs_chooser.choose_time )#</cfoutput></span></td>
									<td></td>
								</tr>
							</cfloop>
						</tbody>
					</table>
					
					
				</div>
				
			</div>
		</li>
	</ul>
</div>